using System;
using System.Collections.Generic;
using System.ByteBuffer;
using tools;

namespace Zjh
{
    /// <summary>
    /// generate by msg tool
    /// 炸金花局玩家结算信息
    /// </summary>
	public class RoundPlayerBillInfo : Dto
	{
		//玩家id
		public long playerId;
		//微信昵称
		public String nickName;
		//结算筹码(包含喜钱)
		public long cedit;
		//喜钱
		public long luck;
		//牌型(0:235,1:单张,2:对子,3:顺子,4:金华,5:顺金,6:豹子)
		public int cardsType;
		//牌
		public List<int> cards = new List<int>();
		

        public RoundPlayerBillInfo() { }

        public RoundPlayerBillInfo(long playerId, String nickName, long cedit, long luck, int cardsType)
        {
            this.playerId = playerId;
            this.nickName = nickName;
            this.cedit = cedit;
            this.luck = luck;
            this.cardsType = cardsType;
        }

        
		public void write(object obj)
		{
			ByteBuffer b = obj as ByteBuffer;
			b.PushLong(playerId);
			b.PushString(nickName);
			b.PushLong(cedit);
			b.PushLong(luck);
			b.PushInt(cardsType);
			b.PushInt(cards.Count);

			foreach (var element in cards)
			{
				b.PushInt(element);
				
			}
			
		}

	    public void read(object obj)
		{
		    MyConverter b = obj as MyConverter;
			playerId = b.toInt64();
			nickName = b.toString();
			cedit = b.toInt64();
			luck = b.toInt64();
			cardsType = b.toInt32();
			int cards_length = b.toInt32();
			for (int i = 0; i < cards_length; ++i)
			{
				cards.Add(b.toInt32());
				
			}
			
		}

	}
}